package main

import (
	"net/http"
	"strconv"
)

func main() {

	http.HandleFunc("/hello", func(writer http.ResponseWriter, request *http.Request) {

		//fmt.Println(request.RemoteAddr, "连接成功")  //r.RemoteAddr远程网络地址
		//fmt.Println("method = ", request.Method) //请求方法
		//fmt.Println("url = ", request.URL.Path)
		//fmt.Println("header = ", request.Header)
		//fmt.Println("body = ", request.Body)

		//writer.Header().Set("Content-Type", "application/json;charset=UTF-8")

		bytes := []byte("wocaosodsadsa")

		writer.Header().Add("Content-Disposition", "attachment;filename=aaa.txt");
		writer.Header().Add("Content-Length", strconv.Itoa(len(bytes)));

		writer.Write(bytes)

		writer.Write([]byte("{\"name\":456}")) //给客户端回复数据



	})

	http.ListenAndServe("127.0.0.1:8028", nil)

}
